<template>
	<Page class="apply-form">
		<div>
			<!-- 顶部区域 -->
			<div class="apply-top" @click="pageClick">
				<img src="~img/lookAround/zfwj_top_back.png" alt="" class="top_back" />
				<div class="apply-top-title1">企业摸排</div>
				<div class="apply-top-title2">千企万户大走访暨小微企业<br />融资协调工作机制</div>
				<div class="share_ma" v-if="showWgy" @click.stop="openShare">
					<img src="~img/lookAround/ydm.png" alt="" />
				</div>
				<!-- <div class="my_identity">
          <div class="my_identity_box">
            <div class="my_identity_title">我的身份：</div>
            <div class="identity_check">
              <van-radio-group v-model="myIdentity" direction="horizontal">
                <van-radio name="0">走访员</van-radio>
                <van-radio name="1" style="margin-left: 100px">企业</van-radio>
              </van-radio-group>
            </div>
          </div>
        </div> -->
			</div>
			<div class="apply-bigBody">
				<div class="apply-body" @click="pageClick" v-if="myIdentity == '0' && showWgy">
					<div class="head_box">
						<img src="~img/lookAround/head_left.png" alt="" class="head_left_img" />
						走访记录
					</div>
					<van-cell title="人员姓名">
						<div slot="right-icon">
							<input placeholder="请输入人员姓名" v-model="form.userName" />
						</div>
					</van-cell>
					<van-cell title="联系方式">
						<!-- <div slot="right-icon">
              <input placeholder="请输入走访人联系方式" v-model="form.phone" />
            </div> -->
						<van-field
							v-model="form.phone"
							label=""
							input-align="right"
							type="tel"
							placeholder="请输入走访人联系方式"
							style="padding: 0 5px"
						/>
					</van-cell>
					<van-cell title="走访时间">
						<div slot="right-icon">
							<div @click="visitDateIshow = true" class="form_checkbox">
								{{ form.visitTime ? form.visitTime : '点击选择日期' }}
								<img src="~img/lookAround/right_kuohao.png" alt="" class="right_kuohao_img" />
							</div>
							<van-calendar
								v-model="visitDateIshow"
								@confirm="visitDateClick"
								:min-date="minDate"
								:max-date="maxDate"
							/>
						</div>
					</van-cell>
					<van-cell title="走访状态">
						<div class="right-is">
							<div slot="right-icon">
								<div @click="visitStatusIshow = true" class="form_checkbox">
									{{ form.visitStatus ? form.visitStatus : '点击选择走访状态' }}
									<img src="~img/lookAround/right_kuohao.png" alt="" class="right_kuohao_img" />
								</div>
							</div>
							<van-popup
								v-model="visitStatusIshow"
								position="bopttom"
								:style="{
									height: '40%',
									left: '0%',
									bottom: '0',
									width: '100%',
								}"
							>
								<van-picker
									title="走访状态"
									show-toolbar
									:columns="visitStatusColumns"
									@confirm="visitStatusonConfirm"
									@cancel="visitStatuscancel"
								/>
							</van-popup>
							<!-- <van-radio-group v-model="form.visitStatus" direction="horizontal">
              <van-radio name="0">已走访</van-radio>
              <van-radio name="1">未走访</van-radio>
            </van-radio-group> -->
						</div>
					</van-cell>
					<van-cell
						title="拜访记录"
						required
						v-if="form.visitStatus == '已走访有意向' || form.visitStatus == '已走访无需求'"
					>
						<div slot="right-icon">
							<input placeholder="请输入拜访记录" v-model="form.visitRecord" />
						</div>
					</van-cell>
				</div>
				<div class="apply-body" @click="pageClick">
					<div class="head_box">
						<img src="~img/lookAround/head_left.png" alt="" class="head_left_img" />
						基本信息
					</div>
					<van-cell title="企业名称" required>
						<div slot="right-icon">
							<input
								style="width: 260px"
								placeholder="输入名称关键字，根据提示直接确认"
								v-model="form.corpName"
								@input="changeValue"
							/>
							<!-- 下拉搜索框 -->
							<div class="search-body" v-show="showSearch" @click.stop="showSearch = false">
								<div
									v-for="(item, index) in bossList"
									:key="index"
									class="search-item"
									v-html="item._source.corpName"
									@click="selectOne(item)"
								></div>
							</div>
						</div>
					</van-cell>
					<van-cell title="统一信用代码" required>
						<div slot="right-icon">
							<input placeholder="请输入统一信用代码" v-model="form.corpCredit" />
						</div>
					</van-cell>
					<van-cell title="企业类型" required>
						<div slot="right-icon">
							<div @click="enterpriseTypeIshow = true" class="form_checkbox">
								{{ form.corpType ? form.corpType : '点击选择企业类型' }}
								<img src="~img/lookAround/right_kuohao.png" alt="" class="right_kuohao_img" />
							</div>
						</div>
						<van-popup
							v-model="enterpriseTypeIshow"
							position="bopttom"
							:style="{ height: '40%', left: '0%', bottom: '0', width: '100%' }"
						>
							<van-picker
								title="企业类型"
								show-toolbar
								:columns="enterpriseTypeColumns"
								@confirm="enterpriseTypeonConfirm"
								@cancel="enterpriseTypecancel"
							/>
						</van-popup>
					</van-cell>
					<van-cell title="注册地址" required>
						<div slot="right-icon">
							<input placeholder="请输入注册地址" />
						</div>
					</van-cell>
					<van-cell title="地址是否与营业执照一致" required>
						<div class="right-is">
							<van-radio-group v-model="form.isDzYyzz" direction="horizontal">
								<van-radio name="1">是</van-radio>
								<van-radio name="0">否</van-radio>
							</van-radio-group>
						</div>
					</van-cell>
					<van-cell title="实际经营地址所在区县" required v-if="form.isDzYyzz == '0'">
						<div class="right-is">
							<div slot="right-icon">
								<div @click="addressDistrictIshow = true" class="form_checkbox">
									{{ form.addressDistrict ? form.addressDistrict : '点击选择区县' }}
									<img src="~img/lookAround/right_kuohao.png" alt="" class="right_kuohao_img" />
								</div>
							</div>
						</div>
					</van-cell>
					<van-cell title="详细地址" required v-if="form.isDzYyzz == '0'">
						<div slot="right-icon">
							<input placeholder="请输入详细地址" v-model="form.detailAddress" />
						</div>
					</van-cell>
					<van-cell title="成立日期" required>
						<!-- <div slot="right-icon">
              <input placeholder="请输入成立日期" v-model="form.esDate" />
            </div> -->
						<div slot="right-icon">
							<div @click="esDateDateIshow = true" class="form_checkbox">
								{{ form.esDate ? form.esDate : '点击选择日期' }}
								<img src="~img/lookAround/right_kuohao.png" alt="" class="right_kuohao_img" />
							</div>

							<van-calendar
								v-model="esDateDateIshow"
								@confirm="esDateDateClick"
								:min-date="minDate"
								:max-date="maxDate"
							/>
						</div>
					</van-cell>
					<van-cell title="企业法人" required>
						<div slot="right-icon">
							<input placeholder="请输入企业法人" v-model="form.corpLegal" />
						</div>
					</van-cell>
					<van-cell title="企业联系人" required>
						<div slot="right-icon">
							<input placeholder="请输入企业联系人" v-model="form.corpUserName" />
						</div>
					</van-cell>
					<van-cell title="企业联系方式" required>
						<!-- <div slot="right-icon">
              <input
                placeholder="请输入企业联系方式"
                v-model="form.corpUserPhone"
              />
            </div> -->
						<van-field
							v-model="form.corpUserPhone"
							label=""
							input-align="right"
							type="tel"
							placeholder="请输入企业联系方式"
							style="padding: 0 5px"
						/>
					</van-cell>
					<van-cell title="用工人数" required>
						<!-- <div slot="right-icon">
              <input placeholder="请输入用工人数" v-model="form.enpNumber" />
            </div> -->
						<van-field
							v-model="form.enpNumber"
							label=""
							input-align="right"
							type="tel"
							placeholder="请输入用工人数"
							style="padding: 0 5px"
						/>
					</van-cell>
					<van-cell title="上年全年营业收入（万元）" required>
						<!-- <div slot="right-icon">
              <input
                placeholder="请输入收入金额"
                v-model="form.snYysr"
                type="number"
              />
            </div> -->
						<van-field
							v-model="form.snYysr"
							label=""
							input-align="right"
							type="number"
							placeholder="请输入收入金额"
							style="padding: 0 5px"
						/>
					</van-cell>
					<van-cell title="是否首贷户" required>
						<div class="right-is">
							<van-radio-group v-model="form.isSd" direction="horizontal">
								<van-radio name="1">是</van-radio>
								<van-radio name="0">否</van-radio>
							</van-radio-group>
						</div>
					</van-cell>
					<van-cell title="企业是否存在融资需求" required>
						<div class="right-is">
							<van-radio-group v-model="form.haveFinNeed" direction="horizontal">
								<van-radio name="1">是</van-radio>
								<van-radio name="0">否</van-radio>
							</van-radio-group>
						</div>
					</van-cell>

					<van-cell title="贷款银行" @click="openBank" v-if="form.haveFinNeed == '1'">
						<div slot="right-icon">
							<div class="bank_input">
								<div class="left">
									<div v-if="selectBanklist.length !== 0">
										<div
											class="bank_tag"
											v-for="(item, index) in selectBanklist"
											:key="item.bankId"
											@click.stop="closebankClick(item, index)"
										>
											{{ item.bankName }}
											<van-icon name="clear" class="bank-tag-icon" />
										</div>
									</div>
									<div v-if="selectBanklist.length == 0" style="color: #ccc">请选择贷款银行</div>
								</div>
								<img src="~img/lookAround/right_kuohao.png" alt="" class="right_kuohao_img" />
							</div>
							<div class="multipleChoices">支持多选</div>
						</div>
					</van-cell>

					<van-cell title="意向贷款银行" @click="openBank1" v-if="form.haveFinNeed == '1'">
						<div slot="right-icon">
							<div class="bank_input">
								<div class="left">
									<div v-if="selectBanklist1.length !== 0">
										<div
											class="bank_tag"
											v-for="(item, index) in selectBanklist1"
											:key="item.bankId"
											@click.stop="closebankClick1(item, index)"
										>
											{{ item.bankName }}
											<van-icon name="clear" class="bank-tag-icon" />
										</div>
									</div>
									<div v-if="selectBanklist1.length == 0" style="color: #ccc">请选择贷款银行</div>
								</div>
								<img src="~img/lookAround/right_kuohao.png" alt="" class="right_kuohao_img" />
							</div>
							<div class="multipleChoices">最多可选 <font style="color: #ca1c1c;">3</font> 家银行</div>
						</div>
					</van-cell>

					<!-- <van-cell title="意向贷款银行" v-if="form.haveFinNeed == '1'">
						<div slot="right-icon">
							<div @click="yxyhClick" class="form_listcheckbox">
								<div class="form_listcheckName" v-if="form.intentionBank" @click.stop="deleteyxyh">
									{{ form.intentionBank }}
									<van-icon name="clear" class="bank-tag-icon" />
								</div>
								<div v-else class="form_listcheckTips">请选择意向银行</div>
								<img src="~img/lookAround/right_kuohao.png" alt="" class="right_kuohao_img" />
							</div>
						</div>
					</van-cell> -->
					<van-cell
						title="意向贷款金额（万元）"
						required
						v-if="form.intentionBank && form.haveFinNeed == '1'"
					>
						<van-field
							v-model="form.intentionLoanAmount"
							label=""
							input-align="right"
							type="number"
							placeholder="请输入意向贷款金额"
							style="padding: 0 5px"
						/>
						<!-- <div slot="right-icon">
              <input
                placeholder="请输入意向贷款金额"
                v-model="form.intentionLoanAmount"
                type="number"
              />
            </div> -->
					</van-cell>
					<van-cell title="开户银行" v-if="form.haveFinNeed == '1'">
						<div slot="right-icon">
							<!-- <div @click="khyhClick" class="form_checkbox">
              {{ form.openBank ? form.openBank : "点击选择意向银行" }}
              <img
                src="~img/lookAround/right_kuohao.png"
                alt=""
                class="right_kuohao_img"
              />
            </div> -->
							<div @click="khyhClick" class="form_listcheckbox">
								<div class="form_listcheckName" v-if="form.openBank" @click.stop="deletekhyh">
									{{ form.openBank }}
									<van-icon name="clear" class="bank-tag-icon" />
								</div>
								<div v-else class="form_listcheckTips">请选择开户银行</div>
								<img src="~img/lookAround/right_kuohao.png" alt="" class="right_kuohao_img" />
							</div>
						</div>
					</van-cell>
					<van-cell title=""> </van-cell>
					<!-- <div class="description">
        <textarea
          rows="8"
          maxlength="200"
          οnchange="this.value=this.value.substring(0, 200)"
          οnkeydοwn="this.value=this.value.substring(0, 200)"
          οnkeyup="this.value=this.value.substring(0, 200)"
          placeholder="提供融资申请补充说明，比如专利、商标等详细信息（200字以内）"
          v-model="applyInstr"
        ></textarea>
      </div> -->
				</div>
			</div>

			<!-- 银行选择弹框 -->
			<transition name="bottomToTop05">
				<bankList
					ref="bankList"
					v-if="showBank"
					@cancel="cancel"
					:bankList="bankList"
					@clickConfirm="clickConfirm"
					@searchBank="searchBank"
				></bankList>
			</transition>

			<div v-if="form.haveFinNeed == '1'" class="a-title">五项标准企业信息收集问卷</div>
			<investigation
				v-show="form.haveFinNeed == '1'"
				ref="investigation"
				@qtSub="qtSub"
			></investigation>
			<button class="theme-btn" @click="submitForm">提交</button>
		</div>
		<transition name="bottomToTop05">
			<!-- <bankList2
				ref="bankList"
				v-if="showBank1"
				@cancel="cancel1"
				:bankList="bankList2"
				@clickConfirm="clickConfirm1"
			></bankList2> -->
			<bankList
				ref="bankList"
				v-if="showBank1"
				@cancel="cancel1"
				:bankList="bankList1"
				@clickConfirm="clickConfirm1"
				@searchBank="searchBank1"
				:limit="3"
			></bankList>
		</transition>
		<transition name="bottomToTop05">
			<bankList2
				ref="bankList"
				v-if="showBank2"
				@cancel="cancel2"
				:bankList="bankList2"
				@clickConfirm="clickConfirm2"
			></bankList2>
		</transition>
		<!-- 区域选择 -->
		<van-popup v-model="addressDistrictIshow" position="bottom">
			<div class="street-top">
				<div style="color: #969799" @click="addressDistrictcancel">取消</div>
				<div @click="handleConfirm">确认</div>
			</div>
			<van-tree-select
				:items="items"
				:active-id.sync="activeId"
				:main-active-index.sync="activeIndex"
				@click-nav="clickLeft"
				@click-item="clickRight"
			/>
		</van-popup>
		<!-- <van-popup
			v-model="addressDistrictIshow"
			position="bopttom"
			:style="{
				height: '40%',
				left: '0%',
				bottom: '0',
				width: '100%',
			}"
		>
			<van-picker
				title="选择区县"
				show-toolbar
				:columns="addressDistrictColumns"
				@confirm="addressDistrictConfirm"
				@cancel="addressDistrictcancel"
			/>
		</van-popup> -->
		<van-overlay :show="showEw" @click="showEw = false">
			<div class="wrapper">
				<div>
					<img src="~img/lookAround/s_ewm.png" alt="" />
					<div>请使用手机扫码打开</div>
				</div>
			</div>
		</van-overlay>
	</Page>
</template>

<script>
	import bankList from '@/components/apply/bankListUnlimited';
	import bankList2 from '@/components/authorize/bankList';
	import investigation from '@/views/cydnQt/investigationForm';
	import { allBankList2 } from '@/interfaces/authorize';
	// import { areaList } from "@vant/area-data";
	import {
		getOrderedBanks,
		getCorpNames,
		insertFinance,
		getNewInfoByCorpKeyV3,
		getObsCorpByNameAndCreditHaveHighLight,
	} from '@/interfaces/mini';
	import { addSbqd } from '@/interfaces/cydnQt';
	import { Dialog } from 'vant';
	import { area } from './area.js';
	export default {
		name: 'demoForm',
		components: {
			bankList,
			bankList2,
			investigation,
		},
		data() {
			return {
				// areaList,
				addressDistrictIshow: false,
				minDate: new Date(2010, 0, 1),
				maxDate: new Date(2025, 12, 31),
				visitStatusIshow: false,
				bankList1: [],
				showBank1: false,
				showBank2: false,
				myIdentity: '0',
				visitDateIshow: false,
				esDateDateIshow: false,
				enterpriseTypeColumns: ['小微企业', '个体工商户', '其他经营主体'],
				visitStatusColumns: ['未走访', '已走访有意向', '已走访无需求'],
				addressDistrictColumns: [
					'高新区',
					'吴中区',
					'相城区',
					'姑苏区',
					'吴江区',
					'工业园区',
					'常熟市',
					'张家港市',
					'昆山市',
					'太仓市',
				],
				enterpriseTypeIshow: false,
				// 企业表单
				form: {
					detailAddress: '',
					userName: '',
					corpLegal: '',
					phone: '',
					isDzYyzz: '',
					corpName: '',
					corpCredit: '',
					person: '',
					phone: '',
					disposition: '',
					yxdkyh: '', // 意向贷款银行
					amount: '',
					isFirst: '',
					visitTime: '',
					visitStatus: '',
					visitRecord: '',
					corpType: '',
					haveFinNeed: '',
					dom: '',
					esDate: '',
					corpUserName: '',
					corpUserPhone: '',
					enpNumber: '',
					snYysr: '', // 企业主营收入
					isSd: '',
					haveFinNeed: '', // 企业是否有融资需求
					intentionLoanAmount: '', // 贷款金额
					intentionBank: '',
					openBank: '',
				},
				applyInstr: '',
				selectBanklist: [],
				selectBanklist1: [],
				bankListAll: [],
				bankList: [],
				bankList1: [],
				bankList2: [],
				radio: '0',
				showBank: false,
				bossList: [],
				showSearch: false,
				jkJbxxSfxxNew: {},
				showWgy: false,
				showEw: false,
				showPopup: false,
				activeIndex: 0,
				activeId: 320508999000,
				items: [],
			};
		},
		computed: {
			// canSub() {
			// 	return Object.values(this.form).some((val) => !val);
			// },
		},
		created() {
			this.showWgy = this.$route.query.from === 'mini_wgy';
			console.log(this.showWgy);
			this.$store.commit('user/setState', {
				attr: 'token_cydn',
				data: 'cydn12345',
			});
			this.initPage();
			if (this.$route.query.checkId) {
				this.selectOneFx(this.$route.query.checkId);
			}
			// this.getAllBankList();
			this.items = area();
		},
		watch: {
			// 'form.corpName' (newval, oldval) {

			// },
			'form.amount'(newval, oldval) {
				const test = newval ? newval.toString().replace(/^[0]+/, '') : 0;
				this.form.amount = test;
				// console.log(test)
				if (test > 100000) this.form.amount = 100000;
				if (test < 0) this.form.amount = 0;
			},
		},
		methods: {
			addressDistrictonConfirm(e) {
				console.log(e, 'ee');
				let str = '';
				for (let i in e) {
					if (i < e.length - 1) {
						str += e[i].name + '-';
					} else {
						str += e[i].name;
					}
				}

				this.form.addressDistrict = str;
				this.addressDistrictIshow = false;
			},
			goArea() {
				this.showPopup = true;
			},
			clickLeft() {
				const areaList = area();
				this.activeId = areaList[this.activeIndex].children[0].id;
			},
			clickRight() {
				console.log(this.activeId, 'activeId');
			},
			handleConfirm() {
				const areaList = area();
				this.form.addressDistrict = areaList[this.activeIndex].text;
				this.form.addressJiedao = areaList[this.activeIndex].children.find(
					(val) => val.id == this.activeId
				).text;
				console.log(this.form, 'this.form');
				this.addressDistrictIshow = false;
			},
			jbxxVerification() {
				if (this.form.corpName == '') {
					this.$toast('请输入企业名称');
					return false;
				}
				if (this.form.corpCredit == '') {
					this.$toast('请输入企业信用代码');
					return false;
				}
				if (this.form.corpType == '') {
					this.$toast('请选择企业类型');
					return false;
				}
				if (this.form.dom == '') {
					this.$toast('请输入注册地址');
					return false;
				}
				if (this.form.isDzYyzz == '') {
					this.$toast('请选择是否与营业执照一致');
					return false;
				}
				if (this.form.isDzYyzz == '0' && this.form.addressDistrict == '') {
					this.$toast('请选择实际经营区县');
					return false;
				}
				if (this.form.isDzYyzz == '0' && this.form.detailAddress == '') {
					this.$toast('请填写详细地址');
					return false;
				}
				if (this.form.esDate == '') {
					this.$toast('请选择成立日期');
					return false;
				}
				if (this.form.corpUserName == '') {
					this.$toast('请输入企业联系人');
					return false;
				}
				if (this.form.corpLegal == '') {
					this.$toast('请输入企业法人');
					return false;
				}
				if (this.form.corpUserPhone == '') {
					this.$toast('请输入企业联系人电话');
					return false;
				}
				if (this.form.corpUserPhone.length > 11) {
					this.$toast('请输入正确联系方式');
					return false;
				}
				if (this.form.enpNumber == '') {
					this.$toast('请输入用工人数');
					return false;
				}
				if (this.form.enpNumber.length > 5) {
					this.$toast('用工人数至多5位');
					return false;
				}
				if (this.form.snYysr == '') {
					this.$toast('请输入上年全年营业收入');
					return false;
				}
				if (this.form.snYysr.length > 8) {
					this.$toast('上年全年营业收入至多8位数');
					return false;
				}
				// 判断是否存在融资需求部分
				if (
					this.form.intentionBank != '' &&
					this.form.intentionLoanAmount == '' &&
					this.form.haveFinNeed == '1'
				) {
					this.$toast('请输入意向贷款金额');
					return false;
				}
				if (
					this.form.intentionBank != '' &&
					this.form.haveFinNeed == '1' &&
					this.form.intentionLoanAmount.length > 8
				) {
					this.$toast('意向贷款金额至多8位');
					return false;
				}
			},
			zfjlVerification() {
				// if (this.form.userName == "") {
				//   this.$toast("请输入人员姓名");
				//   return false;
				// }
				// if (this.form.phone == "") {
				//   this.$toast("请输入走访人员联系方式");
				//   return false;
				// }
				if (this.form.phone.length > 11) {
					this.$toast('请输入正确联系方式');
					return false;
				}
				// if (this.form.visitTime == "") {
				//   this.$toast("请输选择走访时间");
				//   return false;
				// }
				// if (this.form.visitStatus == "") {
				//   this.$toast("请输入走访状态");
				//   return false;
				// }
				if (
					(this.form.visitStatus == '已走访有意向' && this.form.visitRecord == '') ||
					(this.form.visitStatus == '已走访无意向' && this.form.visitRecord == '')
				) {
					this.$toast('请输入走访记录');
					return false;
				}
			},
			deleteyxyh() {
				this.form.intentionBank = '';
			},
			deletekhyh() {
				this.form.openBank = '';
			},

			// clickConfirm1(item) {
			// 	console.log(item, 'itemitem111');
			// 	this.showBank1 = false;
			// 	this.form.intentionBank = item.bankName;
			// 	this.form.yxdkbankId = item.bankId;
			// },

			clickConfirm2(item) {
				console.log(item, 'itemitem222');
				this.showBank2 = false;
				this.form.openBank = item.bankName;
				this.form.khyhbankId = item.bankId;
			},
			cancel1() {
				this.showBank1 = false;
			},
			cancel2() {
				this.showBank2 = false;
			},
			async getAllBankList() {
				const params = {
					area: '镇江市',
					name: '',
					type: 'tax',
				};
				console.log(params, 'params');
				const res = await allBankList2(params);
				console.log(res, 'res222');
				res.data.forEach((element) => {
					element.bankId = element.code;
					element.bankName = element.name;
				});
				// this.bankList1 = JSON.parse(JSON.stringify(res.data));
				// this.bankList2 = JSON.parse(JSON.stringify(res.data));
			},
			yxyhClick() {
				this.initPage();
				this.showBank1 = true;
			},
			khyhClick() {
				// this.initPage();
				this.bankList2 = JSON.parse(JSON.stringify(this.bankListAll));
				this.showBank2 = true;
			},

			enterpriseTypeonConfirm(e) {
				console.log(e);
				this.form.corpType = e;
				this.enterpriseTypeIshow = false;
			},
			visitStatusonConfirm(e) {
				console.log(e);
				this.form.visitStatus = e;
				this.visitStatusIshow = false;
			},
			addressDistrictConfirm(e) {
				console.log(e);
				this.form.addressDistrict = e;
				this.addressDistrictIshow = false;
			},
			enterpriseTypecancel() {
				this.enterpriseTypeIshow = false;
			},
			visitStatuscancel() {
				this.visitStatusIshow = false;
			},
			addressDistrictcancel() {
				this.addressDistrictIshow = false;
			},
			visitDateClick(date) {
				console.log(date, 'date');
				console.log(this.formatDateToYYYYMM(date), '222');
				this.form.visitTime = this.formatDateToYYYYMM(date);
				this.visitDateIshow = false;
			},
			esDateDateClick(date) {
				this.form.esDate = this.formatDateToYYYYMM(date);
				this.esDateDateIshow = false;
			},
			pageClick() {
				this.showSearch = false;
			},
			openShare() {
				this.showEw = true;
				this.pageClick();
			},
			initPage() {
				this.getBankList();
			},
			async getBossList(timer) {
				console.log(timer, 'timer');
				// this.showSearch = true
				const params = {
					keyword: this.form.corpName,
				};
				console.log(params, 'params');
				// const res = await getCorpNames(params);
				const res = await getObsCorpByNameAndCreditHaveHighLight(params);
				console.log(res, '搜索的企业列表');
				if (this.timer === timer) {
					if (res.data.hits.hits.length > 0) {
						// if (res.data.length === 1) {
						//   this.form.corpName = res.data[0].corpName
						//   this.form.corpCredit = res.data[0].corpCredit
						// } else {
						res.data.hits.hits.forEach((ped) => {
							ped._source.corpName = this.deal(ped._source.corpName);
						});
						this.showSearch = true;
						this.bossList = res.data.hits.hits;
						// }
						// console.log(this.bossList, 'bossList')
					} else {
						this.showSearch = false;
					}
				}
			},
			async getBankList(name = '') {
				const params = {};
				console.log(params, 'params');
				const res = await getOrderedBanks(params);
				console.log(res, 'zzzzzzz');
				this.bankListAll = res.data;
				this.bankList = this.bankListAll;
				this.bankList1 = this.bankListAll;
				this.bankList2 = this.bankListAll;
			},
			deal(val) {
				if (this.form.corpName) {
					return val.replace(
						this.form.corpName,
						"<font style='color:#fd485e;'>" + this.form.corpName + '</font>'
					);
				} else {
					return val;
				}
			},

			async selectOne(item) {
				console.log(item, '选中的值');

				this.showSearch = false;
				let params = {
					corpKey: item._source.corpCredit,
				};
				console.log(params, 'params');
				const res = await getNewInfoByCorpKeyV3(params);
				console.log(res, 'res222');
				this.form.corpName = res.data.jkJbxxSfxxNew.d2CorpName;
				this.form.corpCredit = res.data.jkJbxxSfxxNew.d2CreditCode;
				this.form.dom = res.data.jkJbxxSfxxNew.d2Dom;
				this.form.esDate = res.data.jkJbxxSfxxNew.d2Op;
				this.form.enpNumber = res.data.jkJbxxSfxxNew.d2Kjsbrs;
				this.form.corpLegal = res.data.jkJbxxSfxxNew.d2LegalPer;
				// this.form.corpUserName = res.data.jkJbxxSfxxNew.d2LegalPer;
				// this.form.corpUserPhone = res.data.jkJbxxSfxxNew.d2Tel;

				this.jkJbxxSfxxNew = res.data.jkJbxxSfxxNew;
				// res.data.forEach((element) => {
				//   element.bankId = element.code;
				//   element.bankName = element.name;
				// });
			},

			async selectOneFx(corpCredit) {
				this.showSearch = false;
				let params = {
					corpKey: corpCredit,
				};
				console.log(params, 'params');
				const res = await getNewInfoByCorpKeyV3(params);
				console.log(res, 'res222');
				this.form.corpName = res.data.jkJbxxSfxxNew.d2CorpName;
				this.form.corpCredit = res.data.jkJbxxSfxxNew.d2CreditCode;
				this.form.dom = res.data.jkJbxxSfxxNew.d2Dom;
				this.form.esDate = res.data.jkJbxxSfxxNew.d2Op;
				this.form.enpNumber = res.data.jkJbxxSfxxNew.d2Kjsbrs;
				this.form.corpLegal = res.data.jkJbxxSfxxNew.d2LegalPer;
				// this.form.corpUserName = res.data.jkJbxxSfxxNew.d2LegalPer;
				// this.form.corpUserPhone = res.data.jkJbxxSfxxNew.d2Tel;

				this.jkJbxxSfxxNew = res.data.jkJbxxSfxxNew;
				// res.data.forEach((element) => {
				//   element.bankId = element.code;
				//   element.bankName = element.name;
				// });
			},

			cancel() {
				this.showBank = false;
			},
			clickConfirm() {
				this.showBank = false;
				const list = JSON.parse(JSON.stringify(this.bankList));
				this.selectBanklist = list.filter((val) => val.checked);
				this.form.disposition = this.selectBanklist.map((pre) => pre.bankId).join(';');
			},
			clickConfirm1() {
				this.showBank1 = false;
				const list = JSON.parse(JSON.stringify(this.bankList1));
				this.selectBanklist1 = list.filter((val) => val.checked);
				this.form.yxdkyh = this.selectBanklist1.map((pre) => pre.bankName).join(';');
			},
			async submitForm() {
				// 表单校验

				if (this.myIdentity == '0') {
					if (this.zfjlVerification() != false && this.jbxxVerification() != false) {
						if (this.form.haveFinNeed == '1') {
							if (this.$refs.investigation.qtverify()) {
								Dialog.confirm({
									title: '温馨提示',
									message:
										this.form.visitStatus == '未走访'
											? '当前走访状态为：未走访，请注意提交后无法进行修改'
											: '提交后无法进行修改，请确认是否提交',
								})
									.then(() => {
										this.$refs.investigation.goSub();
									})
									.catch(() => {
										return false;
									});
							}
						} else {
							Dialog.confirm({
								title: '温馨提示',
								message:
									this.form.visitStatus == '未走访'
										? '当前走访状态为：未走访，请注意提交后无法进行修改'
										: '提交后无法进行修改，请确认是否提交',
							})
								.then(() => {
									this.toSub();
								})
								.catch(() => {
									return false;
								});
						}
						console.log('判断结束');
					}
				} else {
					if (this.jbxxVerification() != false) {
						if (this.form.haveFinNeed == '1') {
							if (this.$refs.investigation.qtverify()) {
								Dialog.confirm({
									title: '温馨提示',
									message:
										this.form.visitStatus == '未走访'
											? '当前走访状态为：未走访，请注意提交后无法进行修改'
											: '提交后无法进行修改，请确认是否提交',
								})
									.then(() => {
										this.$refs.investigation.goSub();
									})
									.catch(() => {
										return false;
									});
							}
						} else {
							Dialog.confirm({
								title: '温馨提示',
								message:
									this.form.visitStatus == '未走访'
										? '当前走访状态为：未走访，请注意提交后无法进行修改'
										: '提交后无法进行修改，请确认是否提交',
							})
								.then(() => {
									this.toSub();
								})
								.catch(() => {
									return false;
								});
						}
					}
				}
				return;
				// 校验一些信息的填写格式是否真正确
				// 校验手机号码
				const mobileRegExp = utils.regExp.get('mobile');
				if (!mobileRegExp.test(this.form.phone)) {
					this.$toast('请先输入正确的手机号码');
					return;
				}
				if (!this.canSub) {
					this.form.amount = this.form.amount + '';
					const params = {
						...this.form,
						applyInstr: this.applyInstr,
					};
					console.log(params, '提交的内容');
					const res = await insertFinance(params);
					console.log(res, 'res');
					if (res.code == 200) {
						Dialog.alert({
							title: '',
							message: '您的需求已提交至意向银行，请继续完善问卷调查！',
							theme: 'round-button',
							confirmButtonColor: '#008ef0',
						}).then(() => {
							this.$router.push({
								name: 'question',
								query: {
									id: res.data,
								},
							});
						});
					}
				}
			},
			openBank() {
				// this.initPage();
				this.bankList = JSON.parse(JSON.stringify(this.bankListAll));
				this.showBank = true;
			},
			openBank1() {
				// this.initPage();
				this.bankList1 = JSON.parse(JSON.stringify(this.bankListAll));
				this.showBank1 = true;
			},
			changeSearch() {
				this.showSearch = true;
			},
			closebankClick(item, index) {
				// 更新银行的选中状态
				this.bankList.find((pre) => pre.bankId === item.bankId).checked = false;
				this.selectBanklist.splice(index, 1);
				console.log(this.selectBanklist, 'selectBanklist');
			},
			closebankClick1(item, index) {
				// 更新银行的选中状态
				this.bankList1.find((pre) => pre.bankId === item.bankId).checked = false;
				this.selectBanklist1.splice(index, 1);
				console.log(this.selectBanklist1, 'selectBanklist1');
			},
			searchBank(item) {
				this.bankList = this.bankListAll.filter((pre) => pre.bankName.indexOf(item) !== -1);
			},
			searchBank1(item) {
				this.bankList1 = this.bankListAll.filter((pre) => pre.bankName.indexOf(item) !== -1);
			},
			async toSub() {
				let params = JSON.parse(JSON.stringify(this.form));
				params.intentionBank = '';
				params.intentionLoanAmount = '';
				params.loanBank = '';
				if (this.myIdentity == '1') {
					params.userName = '';
					params.phone = '';
					params.visitTime = '';
					params.visitStatus = '';
					params.visitRecord = '';
				}
				console.log(params, 'param22222s');
				const res = await addSbqd(params);
				console.log(res, 'res看一下');
				if (res.code == 200) {
					this.$toast('提交成功');
					window.location.reload();
				} else {
					this.$toast(res.msg);
				}
			},
			async qtSub(id, signPic) {
				console.log(signPic, 'selectBanklist怎么个回事');

				let params = JSON.parse(JSON.stringify(this.form));
				params.answerId = id;
				params.signPic = signPic;
				if (this.myIdentity == '1') {
					params.userName = '';
					params.phone = '';
					params.visitTime = '';
					params.visitStatus = '';
					params.visitRecord = '';
				}
				let bankStr = '';
				if (this.selectBanklist.length > 0) {
					for (let i in this.selectBanklist) {
						if (i < this.selectBanklist.length - 1) {
							bankStr += this.selectBanklist[i].bankName + ',';
						} else {
							bankStr += this.selectBanklist[i].bankName;
						}
					}
				} else {
					bankStr = '';
				}

				params.loanBank = bankStr;
				// params.loanBank=this.form.visitStatus
				console.log(params, 'paramsparamsparams');
				const res = await addSbqd(params);
				console.log(res, 'res看一下');
				if (res.code == 200) {
					this.$toast('提交成功');
					window.location.reload();
				} else {
					this.$toast(res.msg);
				}
			},
			changeValue() {
				this.form.corpCredit = '';
				// 代码实现
				if (this.form.corpName.length > 3) {
					this.timer = new Date().getTime();
					this.getBossList(this.timer);
				} else {
					this.showSearch = false;
				}
			},
			formatDateToYYYYMM(dateStr) {
				// 创建一个Date对象（注意：这里假设dateStr是一个有效的日期字符串）
				const date = new Date(dateStr);

				// 提取年、月、日部分
				const year = date.getFullYear();
				const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始，需要加1，并且确保是两位数
				const day = String(date.getDate()).padStart(2, '0'); // 确保日期是两位数

				// 拼接成YYYY-MM-DD格式
				return `${year}-${month}-${day}`;
			},
		},
	};
</script>

<style lang="scss" scoped>
	@import '@/assets/css/demo/index.scss';
	.myIdentity {
		position: relative;
	}
	.apply-form {
		height: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		.a-title {
			height: 40px;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 22px;
			font-weight: 600;
		}
	}
	.apply-top {
		position: relative;
		border: 0.5px solid transparent;
		// background-image: url("https://zx-1311146360.cos.ap-shanghai.myqcloud.com/wx_h5/wx_h5_top.png");
		// background-image: url("~img/lookAround/zfwj_top_back.png");
		background-size: 100% 100%;
		background-repeat: no-repeat;
		overflow: hidden;
		height: 160px;
		.share_ma {
			position: absolute;
			right: 10px;
			top: 48px;
			z-index: 1;
			> img {
				height: 44px;
			}
		}
		.apply-top-title1 {
			// margin: 40px 0 0 28px;

			font-family: Source Han Sans SC;
			font-weight: 800;
			color: #000;
			position: absolute;
			top: 60px;
			font-size: 30px;
			left: 20px;
			// ================
			/* 设置背景为渐变 */
			background: linear-gradient(to right bottom, #03020a, #1f2c9b);

			/* 强制背景仅显示在文本区域 */
			-webkit-background-clip: text;
			color: transparent; /* 将文字颜色设置为透明，以便仅显示背景 */
		}
		.apply-top-title2 {
			// margin: 6px 0 0 28px;
			font-size: 14px;
			font-family: Source Han Sans SC;
			font-weight: 500;
			color: #000;
			position: absolute;
			top: 105px;
			left: 20px;
		}
	}
	.apply-form {
		padding-bottom: 20px;
		// border: 1px solid red;
	}
	.apply-body {
		padding-top: 10px;
		border: 0px solid transparent;
		background-color: #fff;
		// border: 1px solid red;
		border-top-left-radius: 13px;
		border-top-right-radius: 13px;
		margin-top: -10px;
		.head_box {
			display: flex;
			align-items: center;
			background: #eff6ff;
			font-size: 15px;
			padding: 5px 10px;
			.head_left_img {
				width: 6px;
				margin-right: 5px;
			}
		}

		input {
			background: none;
			outline: none;
			border: none;
			text-align: right;
		}
		input:focus {
			border: none;
		}
		.bank_input {
			width: 200px;
			border: 1px solid #e0e1e5;
			padding: 4px 5px;
			// border-radius: 6px;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.right_kuohao_img {
				width: 12px;
				// position: relative;
				bottom: -5px;
			}
			.bank_tag {
				margin-bottom: 7px;
				// margin-right: 5px;
				display: flex;
				justify-content: space-between;
				align-items: center;
				color: #999999;
				background: #f5f5f5;

				padding: 2px 5px;
				font-size: 12px;
				.bank-tag-icon {
					font-size: 12px;
					margin-left: 4px;
				}
				&:last-of-type {
					margin-bottom: 0;
				}
			}
		}
		.selecttext {
			// width: 500rpx;
			height: 30px;
			line-height: 30px;
			text-align: right;
			color: #999999;
			font-size: 12px;
			font-family: Alibaba PuHuiTi;
			color: #999999;
		}
		.right-is {
			display: flex;
			justify-content: flex-end;
		}
		.search-body {
			position: absolute;
			top: 42px;
			right: 10px;
			width: 240px;
			height: 200px;
			// border: 1px solid red;
			background: #fff;
			z-index: 100;
			box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.1);
			overflow-y: auto;
			.search-item {
				margin: 4px 0 0 8px;
				font-size: 12px;
				font-family: Alibaba PuHuiTi;
				color: #999999;
			}
		}
		.linkman_input {
			width: 140px;
		}
		.description {
			// width: 90%;
			text-align: center;
			textarea {
				width: 90%;
				padding: 4px;
				font-size: 14px;
			}
		}
	}
	.my_identity {
		padding: 0 10px;
		position: absolute;
		top: 171px;
		width: 100%;
		.my_identity_box {
			width: 100%;
			background: #fff;
			position: relative;
			// margin-top: 32px;
			padding: 15px;
			// margin-bottom: 12px;
			border-radius: 10px;
			.my_identity_title {
				font-weight: bold;
			}
			.identity_check {
				margin-top: 20px;
			}
		}
	}

	.top_back {
		width: 100%;
	}
	.form_checkbox {
		display: flex;
		align-items: center;
		color: #aeafbc;
		.right_kuohao_img {
			width: 12px;
			margin-left: 5px;
		}
	}
	.form_listcheckbox {
		display: flex;
		justify-content: space-between;
		align-items: center;
		color: #aeafbc;
		color: #999999;
		border: 1px solid #e0e1e5;
		width: 200px;
		padding: 2px 5px;
		.form_listcheckName {
			padding: 2px 5px;
			background: #f5f5f5;
			font-size: 12px;
		}
		.form_listcheckTips {
			padding: 2px 5px;
			color: rgb(204, 204, 204);
		}
		.right_kuohao_img {
			width: 12px;
			margin-left: 5px;
		}
	}
	.apply-bigBody {
		width: 100%;
		border-radius: 10px;
		padding: 10px;
		margin: auto;
		// margin-top: 10px;
	}
	.multipleChoices {
		font-size: 12px;
		text-align: right;
		color: #999999;
	}
	::v-deep .van-field__control::placeholder {
		color: #757575;
	}
	input::-webkit-input-placeholder {
		color: #757575;
	}
	input:-moz-placeholder {
		color: #757575;
	}
	input::-moz-placeholder {
		color: #757575;
	}
	input:-ms-input-placeholder {
		color: #757575;
	}
	input::placeholder {
		color: #757575;
	}
	.qy_text {
	}
	.mp_text {
	}

	.wrapper {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
		img {
			height: 230px;
		}
		text-align: center;
		color: #fff;
		font-size: 20px;
	}
	.street-top {
		display: flex;
		justify-content: space-between;
		color: #3889ff;
		font-size: 14px;
		padding: 9px 15px;
		border-bottom: 1px solid #e5e5e5;
	}
	::v-deep .van-tree-select__nav-item::before {
		background-color: #3889ff !important;
	}
	::v-deep .van-tree-select__item--active {
		color: #3889ff !important;
	}
</style>
